<<<<<<< HEAD
import axios from "axios"; //引入axios
import {METHOD} from "./config";//引入请求方式和路径

//创建带配置项的axios实例
const instance  = axios.create({
  baseURL:"https://api.it120.cc/small4",//前面共同的路径
  timeout:30000 //请求时间  超出时间
})

//http://www.xxxx.com/v1/api/业务请求接口
//请求的基础方法
export function request(method,url,params){
  switch(method){
    case METHOD.GET:
      return GET(url,params);
    case METHOD.POST:
      return POST(url,params);
  }
}

//GET
function GET(url,params){
  return instance.get(url,params)
}

//POST
function POST(url,params){
  return instance.post(url,params)
}
=======
import axios from 'axios'
import { METHOD } from "./config"

const instance = axios.create({
    baseURL: "https://api.it120.cc/small4",
    timeout: 10000,
    headers:{'Content-Type':'application/x-www-form-urlencoded'},
     transformRequest:[function (data) {
      let ret = ''
      for (let it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
})

instance.interceptors.request.use(function (config) {
    return config
}, function (error) {
    return Promise.reject(error)
})

instance.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    return Promise.reject(error);
});

export function request(method,url,params){
    switch(method){
        case METHOD.GET:
            return GET(url,params);
        case METHOD.POST:
            return POST(url,params)
    }
}

function GET(url,params){
    return instance.get(url,params)
}

function POST(url,params){
    return instance.post(url,params)
}
>>>>>>> aeda2c13c6d9f1bcdcbc764ca2642136ce06f725
